<?php
class recoveryForm extends sfForm
{
    
    
  public function configure()
  {
    //parent::configure();
 
    $this->setWidgets(array(
      'email'   => new sfWidgetFormInputHidden(),
      'codigo'        => new sfWidgetFormInputText(),
      'password'  => new sfWidgetFormInputPassword(array('label' => 'Nueva Contraseña')),
      'password2'  => new sfWidgetFormInputPassword(array('label' => 'Repetir Contraseña')),
	 // 'captcha'	  => new sfWidgetFormReCaptcha(array('public_key' => 'RECAPTCHA_PUBLIC_KEY')),
    ));    
 
    $this->setValidators(array(
      'email'   => new sfValidatorEmail(),
      'codigo'        => new sfValidatorString(array('required'=>true), array('required'=>'Escriba el codigo enviado al email')),
      'password'  => new sfValidatorString(array('required'=>true), array('required'=>'Escribe tu contraseña')),
      'password2'  => new sfValidatorString(array('required'=>true), array('required'=>'Escribe tu contraseña')),
      //'captcha'  => new sfValidatorString(array('required'=>true), array('required'=>'Escribe tu contraseña')),
    ));
    
    //$this->widgetSchema->setHelp('email', 'Your contact email address');
    $decorator = new myWidgetFormSchemaFormatterCustom($this->getWidgetSchema());
  	$this->widgetSchema->addFormFormatter('custom', $decorator);
  	$this->widgetSchema->setFormFormatterName('custom');
         
$this->validatorSchema->setPostValidator(
            new sfValidatorSchemaCompare('password2', sfValidatorSchemaCompare::EQUAL, 'password', array('throw_global_error' => true), array('invalid' => "Las dos contraseñas no coinciden"))
        );

      $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
      
 
    $this->widgetSchema->setNameFormat('recovery[%s]');
    $this->widgetSchema->setFormFormatterName('table');
    
     parent::configure(); 
        $this->disableLocalCSRFProtection(); 
  }
 
}
